package adv7;

public class MyThread1Test2 {
	// 主线程+3个子线程
	public static void main(String[] args) {
		// for (int i = 1; i <= 10; i++) {
		// Thread t = new MyThread1("线程" + i);
		// if (i % 3 == 0)
		// t.setPriority(Thread.MAX_PRIORITY);
		// else if (i % 3 == 1)
		// t.setPriority(Thread.MIN_PRIORITY);
		// else
		// t.setPriority(Thread.NORM_PRIORITY);
		//
		// t.start();//
		// }
		Thread[] hr = new Thread[10];

		for (int i = 1; i <= 10; i++) {
			hr[i - 1] = new MyThread1("线程" + i);
			if (i % 3 == 0)
				hr[i - 1].setPriority(Thread.MAX_PRIORITY);
			else if (i % 3 == 1)
				hr[i - 1].setPriority(Thread.MIN_PRIORITY);
			else
				hr[i - 1].setPriority(Thread.NORM_PRIORITY);

			hr[i - 1].start();//
		}
		for (int i = 0; i < hr.length; i++) {
			try {
				hr[i].join();
			} catch (InterruptedException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}// 主线程等他
		}
		System.out.println("三个线程启动成功了");
	}

}
